package com.me.brainlessbirds.actors.map;

import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.me.brainlessbirds.Assets;
import com.me.brainlessbirds.screens.GameScreen;

public class Water extends Actor
{
	private TextureRegion	rgnCloud	= new TextureRegion();
	private int				num			= 1;
	private float			speed		= 30f;
	private float			upSpeed		= 0.2f;
	private float			time		= 0f;

	public Water(int num, float x, float y)
	{
		this.num = num;
		switch (num)
		{
			case 1:
				this.rgnCloud = new TextureRegion(Assets.get().textureLightWater);
				break;

			case 2:
				this.rgnCloud = new TextureRegion(Assets.get().textureDeepWater);
				break;
		}
		setOrigin(0, 0);
		setPosition(x, y);
		setSize(GameScreen.WIDTH, GameScreen.HEIGHT / 3);
	}

	public TextureRegion getTexture()
	{
		return this.rgnCloud;
	}

	@Override
	public void act(float delta)
	{
		this.time += delta;
		if (this.time > 1f)
		{
			this.time = -1f;
		}

		setX(getX() + this.speed * delta);
		if (getX() >= GameScreen.LEVEL_WIDTH)
		{
			setX(-(getWidth() + getX() - GameScreen.LEVEL_WIDTH));
		}
		switch (this.num)
		{
			case 1:
				setY(getY() + (float) (this.upSpeed * Math.sin(this.time)));
				break;

			case 2:
				setY(getY() - (float) (this.upSpeed * Math.sin(this.time)));
				break;
		}
	}
}
